package com.hopes.bizz.poll.town.entity;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.hopes.bizz.common.core.util.DateUtils;
import com.hopes.bizz.poll.common.constant.enums.PollModDictEnum;
import com.hopes.boss.admin.api.resolver.DictResolver;
import com.hopes.boss.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;

/**
 * @author jie.dai
 */
@Data()
@EqualsAndHashCode(callSuper = false)
public class BaseTownOmDataEntity extends BaseEntity {
    /**
     * 乡镇
     */
    private Long townId;
    /**
     * 数据时间
     */
    private Date dataTime;
    /**
     * 监测数据json对象{"w00000": {key: "w00000", val: "11.2", *** }}
     */
    @TableField(value = "data_json", typeHandler = JacksonTypeHandler.class)
    private JSONObject dataJson;

    /**
     * aqi数据
     * * * */
    private Double aqiData;

    @JsonIgnore
    @TableField(exist = false)
    private String mn;

    /**
     * orgId
     */
    private Long orgId;

    public String getDataTimeStr() {
        return DateUtils.limitMinute(this.dataTime);
    }

    public String getTownIdStr() {
         return DictResolver.getItemLabelByValue(PollModDictEnum.town_info, this.townId);
    }


}
